﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.Statistics;
using FastReport;

namespace MINERP.Statistics.Forms
{
    public partial class FrmShopProductCount : Form
    {
        public FrmShopProductCount()
        {
            InitializeComponent();
        }
        private static FrmShopProductCount instance = null;
        public static FrmShopProductCount GetInstance
        {
            get
            {
                if (instance == null)
                {
                    instance = new FrmShopProductCount();

                }
                return instance;
            }
        }
        ShopProductCountBLL _bll=new ShopProductCountBLL();
        private void FrmShopProductCount_Load(object sender, EventArgs e)
        {
            comboBoxAreas.DataSource = _bll.GetAllAreas();
            comboBoxAreas.DisplayMember = "Area";
            //comboBoxAreas.ValueMember = "Area";
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DataSet set = _bll.GetShopCount(comboBoxAreas.Text, Convert.ToDateTime(dateTimePickerStart.Text),
                                                Convert.ToDateTime(dateTimePickerEnd.Text
                                                    ));
                set.WriteXml(@"C:\windows\xmlData\商户生产信息.xml", XmlWriteMode.WriteSchema);
                Report report = new Report();
                report.Load(Application.StartupPath + "\\Report\\商户生产信息.frx");
                report.Preview = previewControl1;
                report.SetParameterValue("ParaStartTime", dateTimePickerStart.Text);
                report.SetParameterValue("ParaEndTime", dateTimePickerEnd.Text);
                previewControl1.Refresh();
                previewControl1.Show();
                report.Show();
            }catch(Exception ex)
            {
                MessageBox.Show("读取数据失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
               this.Cursor = Cursors.Default;
            }



        }

        private void FrmShopProductCount_FormClosing(object sender, FormClosingEventArgs e)
        {
            instance = null;
        }
    }
}
